在MacSnowleopard上使用Ruby1.9.2和Rail3ruby-1.9.2-p290:001>Date.today=>Sun,25Sep2011ruby-1.9.2-p290:002>Date.tomorrow=>Tue,27Sep2011ruby日期类是否有问题,或者这与我安装ruby的方式有关吗?编辑:ruby-1.9.2-p290:039>Date.current=>Mon,26Sep2011ruby-1.9.2-p290:040>DateTime.now=>Sun,25Sep201120:47:01-0500好吧,railsDate类似乎有点问题。DateTim
proc=Proc.newdo|name|puts"Thankyou#{name}!"enddefthankyieldendproc.call#outputnothing,justfineproc.call('God')#=>ThankyouGod!thank&proc#outputnothing,too.Fine;thank&proc('God')#Error!thank&proc.call('God')#Error!thankproc.call('God')#Error!#So,whatshouldIdoifIhavetopassthe'God'totheprocandusethe
这是我现在所拥有的,它有点管用:defpadding(a,b,c=nil)untila[b-1]a这是它起作用的时候:a=[1,2,3]padding(a,10,"YES")=>[1,2,3,"YES","YES","YES","YES","YES","YES","YES"]a[1,2,3]padding(a,10,1)=>[1,2,3,1,1,1,1,1,1,1]但是当我没有为“c”输入值时它崩溃了a=[1,2,3]padding(a,10)Killed我应该如何附加它以避免崩溃?此外,您建议如何更改此方法以按如下方式使用它:[1,2,3].padding(10)=>[1,2,3,n